﻿using System.Collections.Generic;
using System.Windows.Media;
using Might.Infrastructure.ModelicaDOM;

namespace Might.Modelica.Annotations {
    ///<summary>
    ///</summary>
    [Mapping("Color")]
    public class GraphicsColor  {
        internal Color color;

        ///<summary>
        ///</summary>
        public GraphicsColor() {
            color.A = byte.MaxValue;
        }

        ///<summary>
        ///</summary>
        public GraphicsColor(Color clr) : this() {            
            color.R = clr.R;
            color.G = clr.G;
            color.B = clr.B;
        }

        ///<summary>
        ///</summary>
        ///<param name="red"></param>
        ///<param name="green"></param>
        ///<param name="blue"></param>
        public GraphicsColor(int red, int green, int blue) : this() {
            color.A = byte.MaxValue;
            color.G = (byte)green;
            color.B = (byte)blue;
        }

        ///<summary>
        ///</summary>
        [ArrayIndexMapping(0), ConstructorIndexMapping(0)]
        public int Red {
            get { return color.R; }
            set { color.R = (byte)value; }
        }

        ///<summary>
        ///</summary>
        [ArrayIndexMapping(1), ConstructorIndexMapping(1)]
        public int Green {
            get { return color.G; }
            set { color.G = (byte)value; }
        }

        ///<summary>
        ///</summary>
        [ArrayIndexMapping(2), ConstructorIndexMapping(2)]
        public int Blue {
            get { return color.B; }
            set { color.B = (byte)value; }
        }

        [UnknownMapping]
        public List<object> UnknownItems { get; set; }

        public bool IsDefault {
            get { return color == Colors.Black; }
        }
    }
}